﻿using System;
using System.IO;
using System.Text;
using System.Text.RegularExpressions;

namespace mailbox
{
    class Program
    {
        static void WriteSomething(FileStream fs, string w)
        {
            StreamWriter sw = new StreamWriter(fs, Encoding.UTF8);
            sw.Write(w);
            sw.Close();
        }
        static void ReadSomething(FileStream fs)
        {
            StreamReader sr = new StreamReader(fs);
            string x = sr.ReadToEnd();
            Console.WriteLine(x);
        }
        static void Main(string[] args)
        {
            Regex regex = new Regex(@"^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$");
            String str = "";
            for (int i = 0; i < 10; i++)
            {
                String s = Console.ReadLine();
                if (regex.IsMatch(s))
                {
                    str += s + "\n";
                }
            }


            string path = @"D:\Visual Studio\work\mailbox.txt";
            FileStream fs = new FileStream(path, FileMode.OpenOrCreate);
            WriteSomething(fs, str);
            fs.Close();
        }
    }
}